#!/bin/bash
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install

brew tap homebrew/homebrew-cask
brew tap homebrew/homebrew-cask-versions
brew tap homebrew/cask-fonts

cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask-versions
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask-versions.git

brew install git enpass onedrive iterm2 sublime-text alfred onedrive wechat wechatwebdevtools wechatwork teambition microsoft-edge zerotier-one sourcetree
brew install oss-browser gradle
brew install zsh-autosuggestions zsh-syntax-highlighting zsh-completions font-meslo-for-powerline
brew install homebrew/cask/docker docker-compose docker-compose-completion kubectl

# echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"' >> ~/.zprofile
# export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

# BREW_TAPS="$(brew tap)"
# for tap in core cask{,-fonts,-drivers,-versions}; do
#     if echo "$BREW_TAPS" | grep -qE "^homebrew/${tap}\$"; then
#         # 将已有 tap 的上游设置为本镜像并设置 auto update
#         # 注：原 auto update 只针对托管在 GitHub 上的上游有效
#         git -C "$(brew --repo homebrew/${tap})" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
#         git -C "$(brew --repo homebrew/${tap})" config homebrew.forceautoupdate true
#     else   # 在 tap 缺失时自动安装（如不需要请删除此行和下面一行）
#         brew tap --force-auto-update homebrew/${tap} https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
#     fi
# done

# brew update-reset

# REMOTE=https://gitee.com/mirrors/oh-my-zsh.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"


## .zshrc

# export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"

# source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters
# source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# if type brew &>/dev/null; then
# 	FPATH=$(brew --prefix)/share/zsh-completions:$FPATH
# 	autoload -Uz compinit
# 	compinit
# fi

git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git
./iTerm2-Color-Schemes/tools/import-scheme.sh ./iTerm2-Color-Schemes/schemes/*
rm -rf ./iTerm2-Color-Schemes


